/* Ejercicio 3.36
   ejer3_36.c */
#include <stdio.h>

/* funcion main, el programa inicia aca */
int main( void )
{
    int binary, decimal, a, position;

    printf( "Enter a binary number: " );
    scanf( "%d", &binary );

    decimal = 0;
    a = binary;
    position = 1;

    while ( a != 0 ) {
        decimal = decimal + ( a % 10 ) * position;
        position *= 2;
        a /= 10;
    }

    printf( "%d in decimal is: %d\n", binary, decimal );
	return 0;
} /* fin de la funcion main */
